import request from '../../util/request'

export default {

  /**
   *  添加分类
   * @param params
   * @private
   */
  __api__CategoriesAdd: (params) => {
    return request({
      url: '/categories',
      method: 'post',
      data: params
    })
  },

  /**
   *  删除分类
   * @param cateId
   * @private
   */
  __api__CategoriesDelete: (cateId) => {
    return request({
      url: '/categories/' + cateId,
      method: 'delete'
    })
  },

  /**
   *  更新分类名称
   * @param cateId
   * @param name
   * @private
   */
  __api__CategoriesNameUpdate: (cateId, name) => {
    return request({
      url: '/categories/name',
      method: 'patch',
      data: {cateId: cateId, name: name}
    })
  },

  /**
   *  更新分类的显示状态
    * @param cateId
   * @param show
   * @private
   */
  __api__CategoriesShowUpdate: (cateId, show) => {
    return request({
      url: '/categories/show',
      method: 'patch',
      data: {cateId: cateId, show: show}
    })
  },

  /**
   *  更新分类的备注
   * @param cateId
   * @param remarks
   * @private
   */
  __api__CategoriesRemarksUpdate: (cateId, remarks) => {
    return request({
      url: '/categories/remarks',
      method: 'patch',
      data: {cateId: cateId, remarks: remarks}
    })
  },

  /**
   *  获取分类的属性列表
   * @param cate3Id
   * @private
   */
  __api__CategoriesAttrs: (cate3Id) => {
    return request({
      url: '/categories/attrs/' + cate3Id,
      method: 'get'
    })
  },

  /**
   *  获取分类的规格列表
   * @param cate3Id
   * @private
   */
  __api__CategoriesSpecs: (cate3Id) => {
    return request({
      url: '/categories/specs/' + cate3Id,
      method: 'get'
    })
  },

  /**
   *  删除分类的一个规格
   * @param specId
   * @private
   */
  __api__CategoriesSpecsDelete: (specId) => {
    return request({
      url: '/categories/specs/' + specId,
      method: 'delete'
    })
  },

  /**
   *  删除分类的一个属性
   * @param attrId
   * @private
   */
  __api__CategoriesAttrsDelete: (attrId) => {
    return request({
      url: '/categories/attrs/' + attrId,
      method: 'delete'
    })
  },

  /**
   *  为分类添加规格
   * @param cate3Id
   * @param spec
   * @private
   */
  __api__CategoriesSpecsAdd: (cate3Id, spec) => {
    return request({
      url: '/categories/specs',
      method: 'post',
      data: {cateId: cate3Id, specName: spec}
    })
  },

  /**
   *  为分类添加属性
   * @param cate3Id
   * @param attr
   * @private
   */
  __api__CategoriesAttrsAdd: (cate3Id, attr) => {
    return request({
      url: '/categories/attrs',
      method: 'post',
      data: {cateId: cate3Id, attrName: attr}
    })
  }

}
